<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('项目详情')" />
    <th:block th:include="include :: select2-css" />
</head>

<body>
<div class="main-content">
    <form class="form-horizontal"  id="form-user-edit" th:object="${basTraycodeHead}">

        <!-- [[${item}]]-->

        <!--                <h4 class="form-header h4">基本信息</h4>-->
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">托盘条码号：</label>
                    <div class="col-sm-8">
                        <input name="tHead" th:field="*{tHead}" placeholder="请输入项目名称" class="form-control" type="text" maxlength="30"
                               required readonly>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">是否使用：</label>
                    <div class="col-sm-8">
                        <select id="tStatus" name="tStatus" class="form-control" type="text" th:field="*{tStatus}">
                            <option value="Y">使用</option>
                            <option value="N">不使用</option>
                        </select>
                    </div>
                </div>
            </div>

        </div>


    </form>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<script type="text/javascript">
    var prefix = ctx + "bas/trayCodeHead";


    function submitHandler() {
        var data = $("#form-user-edit").serializeArray();
        console.log(data)
        //TODO 如果沒有选择项目组（项目组为空 不允许提交）
        $.operate.save(prefix + "/edit", data);
    }

    /* 用户管理-修改-选择部门树 */
    function selectDeptTree() {
        var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
        var url = ctx + "system/dept/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero){
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        var body = layer.getChildFrame('body', index);
        $("#treeId").val(body.find('#treeId').val());
        $("#treeName").val(body.find('#treeName').val());
        selectgroups();
        layer.close(index);
    }

    $(function() {
        $('#post').select2({
            placeholder: "请选择岗位",
            allowClear: true
        });
    })
    //分配项目组
    function selectgroups() {
        var deptId = $("#treeId").val();
        var url = ctx + "system/item/selectPrjgroupByDeptId/" + deptId;
        $.get(url, function (result) {
            console.log(result)
            var html = ""
            if(result.length>0){
                for (var i = 0; i < result.length; i++) {
                    html += "<option  value=" + result[i].prjgroupId + ">" + result[i].prjgroupName + "</option>"
                }
            }

            $("#prjGroup").html(html)
        })

    }
</script>
</body>
</html>